package com.tz.colawallet.ui.activity;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.tz.colawallet.R;
import com.tz.colawallet.basecode.base.BaseActivity;
import com.tz.colawallet.ui.biz.SuggestBiz;
import com.tz.colawallet.ui.component.DaggerSuggestComponent;
import com.tz.colawallet.ui.contract.SuggestContract;
import com.tz.colawallet.ui.module.SuggestModule;
import com.tz.colawallet.ui.presenter.SuggestPresenter;

import javax.inject.Inject;

public class SuggestActivity extends BaseActivity implements SuggestContract.View {

    @Inject
    SuggestPresenter presenter;
    @Inject
    SuggestBiz biz;
    LinearLayout backLayout;
    EditText suggest;
    Button submit;

    @Override
    protected void setup() {
        super.setup();
        DaggerSuggestComponent.builder().suggestModule(new SuggestModule(this)).build().inject(this);
        presenter.setBiz(biz);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_suggest;
    }

    @Override
    protected void init() {
        backLayout = findViewById(R.id.back_layout);
        suggest = findViewById(R.id.suggest);
        submit = findViewById(R.id.submit);

        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (suggest.getText().toString().isEmpty()) {
                    showToast("请输入建议与反馈");
                    return;
                }
                presenter.suggest(suggest.getText().toString());
            }
        });

        backLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void initTitle() {

    }

    @Override
    public Context curContext() {
        return this;
    }

    @Override
    public void loginSuccess(Object o) {
        showToast("提交成功");
        finish();
    }

}
